//
//  BCGetStuffStyle.m
//  BangcaiBuy
//
//  Created by lsy on 16/6/21.
//  Copyright © 2016年 BCB. All rights reserved.
//

#import "BCGetStuffStyle.h"

@interface BCGetStuffStyle ()
{
    UILabel *getStyle;
    UILabel *styleLab;
    UILabel *getPrice;
    UILabel *styleLine;
    
    UILabel *getTime;
    UILabel *timeLab;
    UILabel *timeLine;
    
    UILabel *messageLab;
    UILabel *messageField;
    UIImageView *arrow;
    UILabel *meesageLine;
    
    UILabel *coupon;
    UIImageView *couImg;
    UILabel *conField;
    UIImageView *couArrow;
    UILabel *couLine;
    
    UILabel *ticket;
    UIButton *ticketBut;
}

@end

@implementation BCGetStuffStyle
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{
    getStyle = [[UILabel alloc] init];
    getStyle.backgroundColor = [UIColor whiteColor];
    getStyle.font = [UIFont systemFontOfSize:16];
    getStyle.textColor = [UIColor colorWithRed:0.200  green:0.200  blue:0.200 alpha:1];
    
    styleLab = [[UILabel alloc] init];
    styleLab.font = [UIFont systemFontOfSize:14];
    styleLab.textColor = [UIColor colorWithRed:0.522  green:0.522  blue:0.522 alpha:1];
    styleLab.text = @"送货上门";
    styleLab.textAlignment = NSTextAlignmentRight;
    
    getPrice = [[UILabel alloc] init];
    getPrice.font = [UIFont systemFontOfSize:14];
    getPrice.textColor = [UIColor colorWithRed:0.998  green:0.378  blue:0 alpha:1];
    getPrice.text = @" ¥ 50";
    styleLine = [[UILabel alloc] init];
    styleLine.backgroundColor = [UIColor colorWithRed:0.949  green:0.949  blue:0.949 alpha:1];
    
    getTime = [[UILabel alloc] init];
    getTime.backgroundColor = [UIColor whiteColor];
    getTime.font = [UIFont systemFontOfSize:16];
    getTime.textColor = [UIColor colorWithRed:0.200  green:0.200  blue:0.200 alpha:1];
    
    timeLab = [[UILabel alloc] init];
    timeLab.font = [UIFont systemFontOfSize:14];
    timeLab.textColor = [UIColor colorWithRed:0.522  green:0.522  blue:0.522 alpha:1];
    timeLab.text = @"次日上午配送";
    timeLab.textAlignment = NSTextAlignmentRight;
    
    timeLine = [[UILabel alloc] init];
    timeLine.backgroundColor = [UIColor colorWithRed:0.949  green:0.949  blue:0.949 alpha:1];
    
    messageLab = [[UILabel alloc] init];
    messageLab.backgroundColor =[UIColor whiteColor];
    messageField = [[UILabel alloc] init];
    messageField.backgroundColor = [UIColor whiteColor];
    messageLab.font = [UIFont systemFontOfSize:16];
    messageLab.textColor = [UIColor colorWithRed:0.200  green:0.200  blue:0.200 alpha:1];
    
    messageField.text = @"请填写您的需求";
    messageField.textColor = [UIColor colorWithRed:0.682  green:0.682  blue:0.682 alpha:1];
    messageField.font = [UIFont systemFontOfSize:14];
    meesageLine = [[UILabel alloc] init];
    meesageLine.backgroundColor =[UIColor colorWithRed:0.949  green:0.949  blue:0.949 alpha:1];
    arrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"下一步-灰"]];
    
    coupon = [[UILabel alloc] init];
    coupon.font = [UIFont systemFontOfSize:16];
    coupon.textColor = [UIColor colorWithRed:0.200  green:0.200  blue:0.200 alpha:1];
    couImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"优惠券"]];
    
    conField = [[UILabel alloc] init];
    conField.font = [UIFont systemFontOfSize:10];
    conField.backgroundColor = [UIColor clearColor];
    conField.textColor = [UIColor colorWithRed:0.987  green:0.149  blue:0.147 alpha:1];
    couArrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"下一步-灰"]];
    couLine = [[UILabel alloc] init];
    couLine.backgroundColor = [UIColor colorWithRed:0.949  green:0.949  blue:0.949 alpha:1];
    
    ticket = [[UILabel alloc] init];
    ticket.font = [UIFont systemFontOfSize:16];
    ticket.textColor = [UIColor colorWithRed:0.200  green:0.200  blue:0.200 alpha:1];
    
    ticketBut = [UIButton buttonWithType:UIButtonTypeCustom];
    [ticketBut setImage:[UIImage imageNamed:@"选中"] forState:UIControlStateSelected];
    [ticketBut setImage:[UIImage imageNamed:@"未选择"] forState:UIControlStateNormal];
    [ticketBut addTarget:self action:@selector(changeBack:) forControlEvents:UIControlEventTouchUpInside];
    ticket.backgroundColor = [UIColor whiteColor];
    
    getStyle.text = @"配送方式";
    getTime.text = @"配送时间";
    messageLab.text = @"留言";
    coupon.text = @"优惠券";
    conField.text = @"2张可用";
    ticket.text = @"索要发票";
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:getStyle];
    [self.contentView addSubview:styleLab];
    [self.contentView addSubview:getPrice];
    [self.contentView addSubview:styleLine];
    
    [self.contentView addSubview:getTime];
    [self.contentView addSubview:timeLab];
    [self.contentView addSubview:timeLine];
    
    [self.contentView addSubview:messageLab];
    [self.contentView addSubview:messageField];
    [self.contentView addSubview:arrow];
    [self.contentView addSubview:meesageLine];
    
    [self.contentView addSubview:coupon];
    [self.contentView addSubview:couImg];
    [couImg addSubview:conField];
    [self.contentView addSubview:couArrow];
    [self.contentView addSubview:couLine];
    
    [self.contentView addSubview:ticket];
    [self.contentView addSubview:ticketBut];
}

- (void)changeBack:(UIButton *)but{
    but.selected = !but.selected;
}

- (void)layoutSubviews
{
    [getStyle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(5);
        make.left.mas_equalTo(12);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(50);
    }];
    
    [getPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.height.equalTo(getStyle);
        make.width.mas_equalTo(42);
        make.centerY.equalTo(getStyle);
    }];
    
    [styleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(getStyle);
        make.height.equalTo(getStyle);
        make.width.mas_equalTo(100);
        make.right.mas_equalTo(getPrice.mas_left);
    }];
    
    [styleLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(getStyle.mas_bottom);
    }];
    
    [getTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(getStyle.mas_bottom).with.offset(2);
        make.left.mas_equalTo(12);
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(50);
    }];
    
    [timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(getTime);
        make.height.equalTo(getTime);
        make.width.mas_equalTo(150);
        make.right.mas_equalTo(-12);
    }];
    
    [timeLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(getTime.mas_bottom);
    }];
    
    [messageLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(getTime.mas_bottom).with.offset(2);
        make.left.mas_equalTo(12);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(50);
    }];
    
    [arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.height.mas_equalTo(17);
        make.width.mas_equalTo(14);
        make.centerY.equalTo(messageLab);
    }];
    
    [messageField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(getTime.mas_bottom).with.offset(2);
        make.right.mas_equalTo(arrow.mas_left).with.offset(-12);
        make.height.mas_equalTo(50);
    }];
    
    [meesageLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(messageLab.mas_bottom);
    }];
    
    [coupon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(messageLab.mas_bottom).with.offset(2);
        make.left.mas_equalTo(12);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(50);
    }];
    
    [couArrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.height.mas_equalTo(17);
        make.width.mas_equalTo(14);
        make.centerY.equalTo(coupon);
    }];
    
    [couImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(coupon);
        make.right.mas_equalTo(couArrow.mas_left).with.offset(-12);
        make.height.mas_equalTo(24);
        make.width.mas_equalTo(70);
    }];
    
    [couLine mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.height.mas_equalTo(1);
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(coupon.mas_bottom);
    }];
    
    [conField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(22);
        make.height.mas_equalTo(11);
    }];
    
    [ticket mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(coupon.mas_bottom).with.offset(2);
        make.left.mas_equalTo(12);
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(40);
    }];
    
    [ticketBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(ticket.mas_centerY);
        make.width.and.height.mas_equalTo(20);
        make.right.mas_equalTo(-28);
    }];
}

@end
